//
//  BQAuthorController.m
//  BeeQuick
//
//  Created by student on 2017/7/10.
//  Copyright © 2017年 BecomeRich. All rights reserved.
//

#import "BQAuthorController.h"
#import <Masonry.h>

@interface BQAuthorController ()
@property(nonatomic,weak)UIView *Fatherview;
@property(nonatomic,weak)UILabel *authorLabel;
@end

@implementation BQAuthorController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self addAuthorMessage];
}
- (void)viewWillAppear:(BOOL)animated{
    self.title = @"关于作者";
    self.navigationController.navigationBar.hidden = NO;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:  UIBarMetricsDefault];
    self.navigationController.navigationBar.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.tintColor = [UIColor blackColor];
}


- (void)addAuthorMessage{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height)];
    self.Fatherview = view;
    view.backgroundColor = [UIColor groupTableViewBackgroundColor];
    [self.view addSubview:view];
    UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"author"]];
    imageView.contentMode = UIViewContentModeScaleAspectFill;
    imageView.layer.cornerRadius = 45;
    [view addSubview:imageView];
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(view);
        make.top.equalTo(view).offset(50);
    }];
    UILabel *authorLabel = [[UILabel alloc]init];
    authorLabel.text = @"吴晓安";
    self.authorLabel = authorLabel;
    authorLabel.font = [UIFont systemFontOfSize:14];
    [view addSubview:authorLabel];
    [authorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(imageView.mas_bottom).offset(20);
        make.centerX.equalTo(view);
    }];
    NSArray *titleAarray = @[@"邮箱:wuxiaoanios@163.com",
                             @"CitHub地址:https://github.com/ZhongTaoTian",
                             @"新浪微博:http://weibo.com/tianzhongtao",
                             @"博客http://www.jianshu.com/users/5fe7513c7a57/latext_articles"
                             ];
    [self addPersonLabelWithLabelTitleArray:titleAarray];
    NSArray *iconAarray = @[@"小安的GitHub",
                            @"  小安的微博",
                            @"小安的技术博客"
                            ];
    [self addChildButtonWithIconAarray:iconAarray];
    
}


- (void)addChildButtonWithIconAarray:(NSArray <NSString *>*)iconArray{
    
    for (int i = 0 ; i < 3; i ++) {
        UIButton *button = [[UIButton alloc]init];
        [button setTitle:iconArray[i] forState:UIControlStateNormal];
        button.tag = i;
        button.titleLabel.font = [UIFont systemFontOfSize:14];
        [button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.Fatherview addSubview:button];
        [button mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.authorLabel.mas_bottom).offset(180);
            make.leading.equalTo(self.Fatherview).offset(40 + i *110 );
        }];
    }
    
    
    
}

- (void)buttonAction:(UIButton *)button{
    
    switch (button.tag) {
        case 0:
            NSLog(@"BQAuthorController.h小安的GitHub");
            break;
        case 1:
            NSLog(@"BQAuthorController.h小安的微博");
            break;
        case 2:
            NSLog(@"BQAuthorController.h小安的技术博客");
            break;
   
        default:
            break;
    }
    
    
}
- (void)addPersonLabelWithLabelTitleArray:(NSArray <NSString *>*)titleArray{
    
    for (int i = 0; i < 4; i++) {
        UILabel *label = [[UILabel alloc]init];
        label.text = titleArray[i];
        label.textColor = [UIColor grayColor];
        label.font = [UIFont systemFontOfSize:14];
        label.textAlignment = NSTextAlignmentLeft;
        label.numberOfLines = 0;
        [self.Fatherview addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.leading.equalTo(self.Fatherview).offset(40);
            make.trailing.equalTo(self.Fatherview).offset(-40);
            make.top.equalTo(self.authorLabel.mas_bottom).offset(30 + i * 30);
        }];
        
    }
    
}
@end
